// 和登山题一样，只是输出剩余数
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 110;
int h[N], f[N], g[N];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> h[i];
    for (int i = 1; i <= n; ++i)
    {
        f[i] = 1;
        for (int j = 1; j < i; ++j)
            if (h[j] < h[i])
                f[i] = max(f[i], f[j] + 1);
    }
    for (int i = n; i > 0; --i)
    {
        g[i] = 1;
        for (int j = n; j > i; --j)
            if (h[j] < h[i])
                g[i] = max(g[i], g[j] + 1);
    }
    int res = 0;
    for (int i = 1; i <= n; ++i)
        res = max(res, f[i] + g[i] - 1);
    cout << n - res << endl;
    return 0;
}
